package org.csu.mybigpro.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.csu.mybigpro.domain.Test;
import org.csu.mybigpro.persistence.TestMapper;
import org.csu.mybigpro.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private TestMapper testMapper;

    @Override
    public void saveTest(Test test) {
        // 使用你自定义的 @Insert 注解方法
        testMapper.insertTest(test);
    }

    @Override
    public Test getTestById(Long id) {
        return testMapper.selectById(id);
    }

    @Override
    public List<Test> getAllTests() {
        return testMapper.selectList(null);
    }

    @Override
    public void updateTest(Test test) {
        testMapper.updateById(test);
    }

    @Override
    public void deleteTest(Long id) {
        testMapper.deleteById(id);
    }

    @Override
    public List<Test> getTestByName(String testName) {
        QueryWrapper<Test> wrapper = new QueryWrapper<>();
        wrapper.like("name", testName);
        return testMapper.selectList(wrapper);
    }
}
